package edu.towson.greenteam.comment;
import java.util.Iterator;


public class CCVisibleItr implements Iterator<Comment>
{
	protected Comments data;
	protected int index = 0;
	
	public CCVisibleItr() {

	}
	public CCVisibleItr(final Comments comments) {
		setData(comments);
	}
	
	public void setData(final Comments comments) {
	    this.data = comments;
	    index = 0;
	}

	@Override
	public boolean hasNext() {
		return (index < data.size()-1);
	}

	@Override
	public Comment next() 	{
		
		while (hasNext()) {
			if (data.get(index).isVisible() == false) {
				Comment cmt=data.get(index);
				index++;
				return cmt;
			}
			else
				index++;
		}
		return null;
		//throw new IndexOutOfBoundsException("only " + data.size() + " elements");
		
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException("Does not implement the remove method");
	}
	
	public boolean hasPrevious() {
		return index > 0;
	}
	
	public Comment previous() {
		return null;
		
	}
	
	public void reset() {
		index = 0;
	}

}
